package com.example;

import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.JedisPoolConfig;

import java.util.HashSet;
import java.util.Set;

public class JedisClusterTest {

    public static void main(String[] args) {
        JedisPoolConfig config = new JedisPoolConfig();
        Set<HostAndPort> jedisClusterNode = new HashSet<HostAndPort>();
        jedisClusterNode.add(new HostAndPort("192.168.2.101", 7001));
        jedisClusterNode.add(new HostAndPort("192.168.2.101", 7002));
        jedisClusterNode.add(new HostAndPort("192.168.2.101", 7003));
        jedisClusterNode.add(new HostAndPort("192.168.2.101", 7004));
        jedisClusterNode.add(new HostAndPort("192.168.2.101", 7005));
        jedisClusterNode.add(new HostAndPort("192.168.2.101", 7006));
        JedisCluster jedisCluster = new JedisCluster(jedisClusterNode, config);

        jedisCluster.set("name:003", "zoro3");
        String s = jedisCluster.get("name:003");
        System.out.println(s);
    }

}
